<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <title>飞腾会-FitaClub</title>
  <%@ include file="/WEB-INF/include/meta.jsp" %>
  <%@ include file="/WEB-INF/include/css.jsp" %>
</head>
<!-- end header -->

<body>
<div class="page-group">
  <div class="page page-current bg-light-gray">
    <header class="bar bar-nav fita-header">
      <a href="javascript:history.back(-1);" class="icon icon-left pull-left"></a>
      <a class="icon icon-menu pull-right open-panel"></a>
      <h1 class="title">我的订单</h1>
    </header>
    <div class="content">
      <div class="buttons-tab fixed-tab fita-buttons-tab" data-offset="54">
        <%--           <a href="${ctx.host}/orders?status=STAYING" class=" button">保留预定</a>
         --%> <a href="${ctx.host}/orders?status=UNPAID" class="active button">待支付</a>
        <a href="${ctx.host}/orders?status=PAID" class="button">已支付</a>
        <a href="${ctx.host}/orders?status=CONSUMED" class="button">已完成</a>
      </div>

      <div class="list order-list-layout">
        <c:forEach items="${orders}" var="order">
          <div class="card fita-card">
            <div class="card-content">
              <div class="card-content-inner">
                <a href="${ctx.host}/orders/${order.id}">
                  <div class="row no-gutter cars-detail">
                    <div class="col-33 cars-type">
                      <c:choose>
                        <c:when test="${persist.modelGroups[order.details.carInfo.modelName] != null}">
                          <img src="${cloudContext.domain}/${persist.modelGroups[order.details.carInfo.modelName].picture}"/>
                        </c:when>
                        <c:otherwise>
                          <img src="${order.details.carInfo.picture}"/>
                        </c:otherwise>
                      </c:choose>
                    </div>
                    <div class="col-66 price-box">
                      <div class="location">
                        <div class="item">
                          <p>${order.pickupLocation}</p>
                          <span class="time"><fmt:formatDate value="${order.pickupDate}" pattern="MM-dd HH:mm"/></span>
                        </div>
                        <div class="item day"><p class="no-margin">${order.rentDay}天</p></div>
                        <div class="item">
                          <p>${order.returnLocation }</p>
                          <span class="time"><fmt:formatDate value="${order.returnDate}" pattern="MM-dd HH:mm"/></span>
                        </div>
                      </div>
                      <div class="" style="margin-top: .5rem;">
                        <p class="no-margin">使用人: ${order.customerName} ${order.customerPerfix}</p>
                        <p class="no-margin">Email:${order.customerEmail }</p>
                      </div>
                    </div>
                  </div>

                  <div class="row">
                    <div class="col-25">${order.vehicleBrand}<br>或类似车型</div>
                    <div class="col-75 text-right">
                      <c:set var="exchangeRate" value="${persist.exchangeRate(order.currencyCode)}"/>
                      <c:choose>
                        <c:when test="${order.type.arrivepay}">
                          <div class="row">
                            <div class="col-50">
                              <p class="no-margin ">订单金额：
                                  <%--
                                                                        <div class="current-price old-price">${exchangeRate.currencySymbol}<fmt:formatNumber value="${order.retailAmount/100}" type="number" maxFractionDigits="2" pattern="0.00"/></div>
                                  --%>
                              <div class="current-price new-price">${exchangeRate.currencySymbol}<fmt:formatNumber
                                      value="${order.retailAmount/100}" type="number" maxFractionDigits="2"
                                      pattern="0.00"/></div>
                              </p>
                            </div>
                            <div class="col-50">
                              <p class="no-margin">佣金：
                              <div class="current-price">${exchangeRate.currencySymbol}<fmt:formatNumber
                                      value="${order.agentCommission}" type="number" maxFractionDigits="2"
                                      pattern="0.00"/></div>
                              </p>
                            </div>
                          </div>
                          <p class="no-margin" style="font-size:13px;">取消截止日期：<fmt:formatDate
                                  value="${order.cancelEndDate}" pattern="yyyy年MM月dd日 HH:mm"/></p>
                        </c:when>
                        <c:otherwise>
                          <p class="no-margin ">订单金额：
                          <c:choose>
                            <c:when test="${not empty order.userCouponId}">
                              <div class="current-price old-price">￥<fmt:formatNumber
                                      value="${order.cnyPayPrice}" type="number" maxFractionDigits="2"
                                      pattern="0.00"/></div>
                              <div class="current-price new-price">￥<fmt:formatNumber
                                      value="${persist.loadCnyPrice(order.id,order.userCouponId)}"/></div>
                            </c:when>
                            <c:otherwise>
                              <div class="current-price new-price">￥<fmt:formatNumber
                                      value="${order.cnyPayPrice}"
                                      type="number" maxFractionDigits="2" pattern="0.00"/></div>
                            </c:otherwise>
                          </c:choose>
                          </p>
                          <p class="no-margin" style="font-size:13px;">支付截止日期：<fmt:formatDate
                                  value="${order.payEndDate}" pattern="yyyy年MM月dd日 HH:mm"/></p>
                        </c:otherwise>
                      </c:choose>
                    </div>
                  </div>
                </a>
                <div class="clearfix text-right">
                  <c:if test="${order.couldCancelOrder}">
                    <a href="javascript:void(0);" data-href="${ctx.host}/orders/${order.id}/cancel"
                       data-order="${order.id}" data-agent="${order.agent.mobile}"
                       class="order-button cancel-button disable cancelOrder">取消订单</a>
                  </c:if>
                  <c:if test="${!order.couldCancelOrder}">
                    <a href="#" class="order-cancel">取消订单</a>
                  </c:if>
                  <c:if test="${order.type.arrivepay}">
                    <a href="#" class="order-cancel">到付订单</a>
                  </c:if>
                  <c:if test="${!order.type.arrivepay}">
                    <a href="${ctx.host}/shopping/result?type=pay&orderId=${order.id}"
                       class="order-button cancel-button">立即支付</a>
                  </c:if>
                </div>
              </div>
            </div>
          </div>
        </c:forEach>
      </div>
    </div>
  </div>
  <div class="panel-overlay"></div>
  <div class="panel panel-right panel-cover fita-panel">
    <div class="list-block contacts-block no-margin">
      <p class="menu-title close-panel">关闭</p>
      <ul>
        <li>
          <a href="${ctx.host}/cars/search" class="item-content item-link">
            <div class="item-inner">
              <div class="item-title">立即租车</div>
            </div>
          </a>
        </li>
        <%-- <li>
          <a href="${ctx.host}/orders" class="item-content item-link">
            <div class="item-inner">
              <div class="item-title">我的订单</div>
            </div>
          </a>
        </li> --%>
        <li>
          <a href="${ctx.host}/profile" class="item-content item-link">
            <div class="item-inner">
              <div class="item-title">个人中心</div>
            </div>
          </a>
        </li>
      </ul>
    </div>
  </div>

</div>
<a ctx.host="/orders/orders-detail">订单详情页</a>

<%@ include file="/WEB-INF/include/script.jsp" %>
<d:resource type="script" root="${ctx.resource}/build" src="js/page/order/order-list.js"/>
<script type="text/javascript">
    require(['page/order/order-list'], function (page) {
        page.init()
    })
</script>


</body>
</html>